use uuid::Uuid;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
#[derive(Debug, Clone)]
pub struct Wire {
    id: String,
    points: Vec<js_sys::Array>,
}

#[wasm_bindgen]
impl Wire {
    #[wasm_bindgen(constructor)]
    pub fn new(points: Vec<js_sys::Array>) -> Wire {
        Wire {
            id: Uuid::new_v4().to_string(),
            points,
        }
    }

    #[wasm_bindgen(js_name = setPoints)]
    pub fn set_points(&mut self, value: Vec<js_sys::Array>) {
        self.points = value;
    }

    #[wasm_bindgen(js_name = getPoints)]
    pub fn get_points(&self) -> Vec<js_sys::Array> {
        self.points.clone()
    }
}
